import java.awt.Color;
import java.awt.Panel;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;


public class BoardAWT extends Panel implements MouseListener
{
	private static final long serialVersionUID = 1L;
	private HolesAWT[][] holes = new HolesAWT[10][10];
	private int player = 1;
	
	public void setPlayer(int player) 
	{
		this.player = player;
	}

	public int getPlayer() 
	{
		return player;
	}
	
	public BoardAWT()
	{
		this.setLayout(null);
		int y = 0;
		for (int i = 0; i<10;i++)
		{
			int x = 0;
			for (int j = 0; j<10; j++)
			{
				holes[i][j] = new HolesAWT();
				holes[i][j].addMouseListener((MouseListener) this);
				holes[i][j].setIs(-1);
				holes[i][j].setCol(Color.WHITE);
				holes[i][j].setBounds(x, y, 30, 30);
				add(holes[i][j]);
				x += 35;
			}
			y += 35;
		}
	}
	
	public void mousePressed(MouseEvent e)
	{
		HolesAWT source = (HolesAWT) e.getSource();
		if ((getPlayer() == 1) && (source.is == -1))
		{
			source.setIs(0);
			source.setCol(Color.RED);
			source.repaint();
			setPlayer(2);
		}
		else 
			if ((getPlayer() == 2) && (source.is == -1))
			{
				source.setIs(1);
				source.setCol(Color.GREEN);
				source.repaint();
				setPlayer(1);
			}			
	}

	public void mouseClicked(MouseEvent e){}

	public void mouseEntered(MouseEvent e) {}

	public void mouseExited(MouseEvent e) {}

	public void mouseReleased(MouseEvent e) {}
}
